package com.party.course.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.party.common.annotation.Log;
import com.party.common.core.controller.BaseController;
import com.party.common.core.domain.AjaxResult;
import com.party.common.enums.BusinessType;
import com.party.common.utils.SecurityUtils;
import com.party.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.party.course.domain.PayGroup;
import com.party.course.service.IPayGroupService;
import com.party.common.core.page.TableDataInfo;

/**
 * 交付小组Controller
 *
 * @author ruoyi
 * @date 2025-05-29
 */
@RestController
@RequestMapping("/course/PayGroup")
public class PayGroupController extends BaseController {
    @Autowired
    private IPayGroupService payGroupService;

    /**
     * 查询交付小组列表
     */
//@RequiresPermissions("course:PayGroup:list")
    @GetMapping("/list")
    public TableDataInfo list(PayGroup payGroup) {
        startPage();
        List<PayGroup> list = payGroupService.findList(payGroup);
        return getDataTable(list);
    }

    @GetMapping("/all")
    public AjaxResult all() {
        return AjaxResult.success(payGroupService.findAllByCreate(SecurityUtils.getUserIdStr()));
    }

    /**
     * 导出交付小组列表
     */
    //@RequiresPermissions("course:PayGroup:export")
    @Log(title = "交付小组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PayGroup payGroup) {
        List<PayGroup> list = payGroupService.findList(payGroup);
        ExcelUtil<PayGroup> util = new ExcelUtil<PayGroup>(PayGroup.class);
        util.exportExcel(response, list, "交付小组数据");
    }

    /**
     * 获取交付小组详细信息
     */
    //@RequiresPermissions("course:PayGroup:query")
    @GetMapping(value = "/view/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(payGroupService.view(id));
    }

    /**
     * 新增交付小组
     */
    //@RequiresPermissions("course:PayGroup:add")
    @Log(title = "交付小组", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PayGroup payGroup) {
        return toAjax(payGroupService.add(payGroup));
    }

    /**
     * 修改交付小组
     */
    //@RequiresPermissions("course:PayGroup:edit")
    @Log(title = "交付小组", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody PayGroup payGroup) {
        return toAjax(payGroupService.updateEntity(payGroup));
    }

    /**
     * 删除交付小组
     */
    //@RequiresPermissions("course:PayGroup:remove")
    @Log(title = "交付小组", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(payGroupService.deleteIds(Arrays.asList(ids)));
    }
}
